import del from "rollup-plugin-delete";
import copy from "rollup-plugin-copy";
import typescript2 from "rollup-plugin-typescript2";
import vue from "rollup-plugin-vue";
import terser from "@rollup/plugin-terser";
import dts from "rollup-plugin-dts";

const tsconfigOverride = {
  include: [
    "packages/components/**/*.ts",
    "packages/components/**/*.vue",
    "shim-vue.d.ts",
  ],
  compilerOptions: {
    declaration: true,
    declarationDir: "dist/components/types",
    declarationMap: true,
  },
};

export default {
  input: "packages/components/index.ts",
  output: {
    dir: "dist/components",
    format: "es",
  },
  external: ["vue", "@s900/utils"],
  plugins: [
    del({ targets: "dist/components" }),
    vue({ include: ["**/*.vue"] }),
    typescript2({
      tsconfig: "tsconfig.app.json",
      tsconfigOverride: tsconfigOverride,
      useTsconfigDeclarationDir: true,
      include: ["packages/components/**/*.ts"],
    }),
    terser(),
    copy({
      targets: [
        {
          src: "packages/components/package.json",
          dest: "dist/components",
          rename: "package1.json",
        },
      ],
    }),
  ],
} as import("rollup").RollupOptions;

export const dtsConfig = {
  input: "dist/components/types/components/index.d.ts",
  output: {
    file: "dist/components/types/index.d.ts",
    format: "es",
  },
  plugins: [dts()],
} as import("rollup").RollupOptions;
